﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CSharpDesign.DAL;
using CSharpDesign.Scripts;
using CSharpDesign.BLL;

namespace CSharpDesign.Admin
{
    public partial class AddNews : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.DataSource = data.GetDataReader("select * from Infotype");
                DropDownList1.DataValueField = "id";
                DropDownList1.DataTextField = "name";
                DropDownList1.DataBind();

            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            try
            {
                AddNewsService ans = new AddNewsService();
                string name = title.Text.ToString().Trim();
                string content = content1.Value;
                string typeid = DropDownList1.SelectedValue;
                string TypeName = DropDownList1.SelectedItem.Text;
                ans.AddNews(name, content, typeid, TypeName);
                Alert.AlertAndRedirect("添加成功", "addnews.aspx");
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }
    }

}